﻿Imports System.Data.OleDb
Imports System.Data
Public Class Upload

    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim myGUID = Guid.NewGuid()
        Dim newFileName As String = myGUID.ToString() & ".jpg"
        Dim fileLocationOnServerHardDisk = Request.MapPath("pictures") & "/" & newFileName
        fu_Picture.SaveAs(fileLocationOnServerHardDisk)
        Dim oleDbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into Dabka (Dabka_Name,Dabka_Country,Dabka_Description,Dabka_Ryhthm,Dabka_Members,Dabka_Gender,Dabka_Picture,Dabka_URL) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tb_Name.Text)
        cmd.Parameters.AddWithValue("@f2", tb_country.Text)
        cmd.Parameters.AddWithValue("@f3", tb_description.Text)
        cmd.Parameters.AddWithValue("@f4", tb_rythm.Text)
        cmd.Parameters.AddWithValue("@f5", tb_members.Text)
        cmd.Parameters.AddWithValue("@f6", tb_gender.Text)
        cmd.Parameters.AddWithValue("@f7", "pictures/" & newFileName)
        cmd.Parameters.AddWithValue("@f8", tb_url.Text)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("confirmation.aspx")
    End Sub
End Class